package com.luyou.utils;


import java.net.URL;

/**
 * 读取Resources资源
 */
public final class ResourcesUtils {

    //当前资源路径
    private static final String ROOT_PATH;

    static {
        URL resource = ResourcesUtils.class.getClassLoader().getResource("");
        if(resource != null){
            ROOT_PATH = resource.getPath();
        }else {
            ROOT_PATH = "";
        }
    }

    /**
     * 获取资源的绝对路径
     * @param filePath resource下的相对路径
     * @return 资源文件的绝对路径
     */
    public static String getResourceFileAbsolutePath(String filePath){
        return ROOT_PATH + filePath;
    }
}
